package com.example.societiesSystem;

import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;

import java.net.InetAddress;
import java.net.UnknownHostException;


// Generated by https://start.springboot.io
// 优质的 spring/boot/data/security/cloud 框架中文文档尽在 => https://springdoc.cn
@Slf4j
@EnableWebMvc
@MapperScan("com.example.societiesSystem.mapper")
@SpringBootApplication
public class SocietiesSystemApplication {

    public static void main(String[] args) throws UnknownHostException {
        ConfigurableApplicationContext application = SpringApplication.run(SocietiesSystemApplication.class, args);
        Environment env = application.getEnvironment();
        // 获取应用名称
        String applicationName = env.getProperty("spring.application.name");
        // 获取ip
        String host = InetAddress.getLocalHost().getHostAddress();
        // 获取端口
        String port = env.getProperty("server.port");
        // 获取上下文路径
        String contextPath = env.getProperty("server.servlet.context-path");

        log.info("\n----------------------------------------------------------\n" +
                        "\tApplication '{}' is running! Access URLs:\n" +
                        "\tLocal: \t\thttp://localhost:{}{}\n" +
                        "\tExternal: \thttp://{}:{}{}\n" +
                        "\tDoc: \t\thttp://{}:{}{}/doc.html\n" +
                        "----------------------------------------------------------",
                applicationName,
                port, contextPath,
                host, port, contextPath,
                host, port, contextPath);
    }

}
